<?php 
$users = $mvc->getObject(UsersService::USERS);
$categories = $mvc->getObject(CategoryService::CATEGORY);
$subcategories = $mvc->getObject(SubCategoryService::SUBCATEGORY);
$regions = $mvc->getObject(RegionService::REGIONS);
$countries = $mvc->getObject(CountryService::COUNTRY);
$count = $mvc->getObject("count");
$pages = $mvc->getObject("pages");
?>
<div class="wrapLSearch">
	<div class="greyBox">
		<div class="viewBox viewBoxA">
			<div class="cT"><em class="cL"></em><em class="cR"></em></div>
			<div class="cL">
				<div class="cR">
					<div class="bodyBox">
						<h2>Find company</h2>
						<form action="/companies.html" method="get">
							<div class="unitBSearch">
								<p>
									<input name="company" class="inpTxt" type="text"  value="<? if(isset($_GET['order_name'])) echo $_GET['order_name']; ?>"/>
									<button name="search" type="submit"><span><strong>Search</strong></span></button>
								</p>
								<p class="itemFilter">
									<span class="item1FilterOpen"><a href="#" title="Advanced search">Advanced search</a></span>
								</p>
								<div class="unitFilter">
									<dl>
										<dt>_i18n{Industry}:</dt>
										<dd>
											<label>_i18n{Category}</label>
											<select name="cat_id" class="gCategory">
												<option value="all">all</option>
										<?php			if (isset($categories) && $categories!=NULL){ 
					foreach($categories as $key=>$category){ ?>
												<option <?php echo isset($_GET['cat_id'])&&$category[CategoryService::ID]==$_GET['cat_id'] ? "selected='selected'" : NULL ; ?> value="<?php echo $category[CategoryService::ID] ?>"><?php echo $category[CategoryService::CAT_NAME] ?></option>
										<?php 				} 
				} ?>
											</select>
											<label>_i18n{SubCategory}</label>
											<select name="subcat_id" class="gSubCategory">
												<option value="all">all</option>
									<?php			if (isset($subcategories) && $subcategories!=NULL){ 
					foreach($subcategories as $key=>$subcategory){ ?>						
												<option <?php echo isset($_GET['subcat_id'])&&$subcategory[SubCategoryService::ID]==$_GET['subcat_id'] ? "selected='selected'" : NULL ; ?> value="<?php echo $subcategory[SubCategoryService::ID] ?>"><?php echo $subcategory[SubCategoryService::SUBCAT_NAME] ?></option>
									<?php 				} 
				} ?>
											</select>
										</dd>
									</dl>
									<dl>
										<dt>_i18n{Location}:</dt>
										<dd>
											<label>_i18n{Country}</label>
											<select name="country">
												<option value="all">all</option>
									<?php			if (isset($countries) && $countries!=NULL){ 
					foreach($countries as $key=>$country){ ?>						
												<option <?php echo isset($_GET['country'])&&$country[CountryService::ID]==$_GET['country'] ? "selected='selected'" : NULL ; ?> value="<?php echo $country[CountryService::ID] ?>"><?php echo $country[CountryService::COUNTRY_NAME] ?></option>
									<?php 				} 
				} ?>
											</select>
											<label>_i18n{Region}</label>
											<select name="region">
												<option value="all">all</option>
										<?php			if (isset($regions) && $regions!=NULL){ 
					foreach($regions as $key=>$region){ ?>
												<option <?php echo isset($_GET['region'])&&$region[RegionService::ID]==$_GET['region'] ? "selected='selected'" : NULL ; ?> value="<?php echo $region[RegionService::ID] ?>"><?php echo $region[RegionService::REGION_NAME] ?></option>
										<?php 				} 
				} ?>
											</select>
										</dd>
									</dl>
								</div>
							</div>
							
							<div class="unitESearch">
								<div class="unitPagination unitTPagination">
									<p>_i18n{found} <span><?php echo $count;?></span> _i18n{results for your request}</p>
									<ul>
										<?php for($i=0; $i<$pages; $i++){ ?>
											<li>
											<?php if(isset($_GET['page'])&&$_GET['page']==$i+1  || !isset($_GET['page'])&&$i==0) { ?>
												<span><?php echo $i+1; ?></span>
											<?php }else{ ?>
												<a href="/view-orders.html?&page=<?php echo $i+1; ?>
													<?php echo isset($_GET['category_id']) ? '&category_id='.$_GET["category_id"] : NULL ; ?>
													<?php echo isset($_GET['subcategory_id']) ? '&subcategory_id='.$_GET["subcategory_id"] : NULL ; ?>
													<?php echo isset($_GET['country_id']) ? '&country_id='.$_GET["country_id"] : NULL ; ?>
													<?php echo isset($_GET['region_id']) ? '&region_id='.$_GET["region_id"] : NULL ; ?>
													<?php echo isset($_GET['price_from']) ? '&price_from='.$_GET["price_from"] : NULL ; ?>
													<?php echo isset($_GET['price_until']) ? '&price_until='.$_GET["price_until"] : NULL ; ?>
													<?php echo isset($_GET['order_name']) ? '&order_name='.$_GET["order_name"] : NULL ; ?>
													<?php echo isset($_GET['onpage']) ? '&onpage='.$_GET["onpage"] : NULL ; ?>
													<?php echo isset($_GET['search']) ? '&search='.$_GET["search"] : NULL ; ?>" title="1">
												<?php echo $i+1; ?>
												</a>
											<?php }?>
											</li>
										<?php } ?>
									</ul>
								</div>
								<div class="viewLSearch">
									<?php if (isset($users)&&$users!=NULL){?>
										<?php foreach($users as $key=> $user){?>
										<div class="unitLSearch">
											<div class="itemImg">
												<img src="<?php echo $user[UsersService::AVATAR] ?>" alt="<?php echo $user[UsersService::COMPANY] ?>"/>
											</div>
											<div class="itemText">
												<h3><a href="/company.html?id=<?php echo $user[UsersService::ID]?>" title="<?php echo $user[UsersService::COMPANY] ?>"><?php echo $user[UsersService::COMPANY] ?></a></h3>
												<p><?php echo $user[UsersService::COMPANY_DESC] ?></p>
												<div class="unitEqColumns">
													<dl>
														<dt>_i18n{rating}:</dt>
														<dd>
															<div class="unitRating">
																<div class="simpleRating">
																	<ul>
																		<li class="itemCurrent" style="width:<?php echo $user['vote']?>%"></li>
																	</ul>
																	<p><strong><?php echo $user['count']?></strong> (<?php echo round($user['vote'])?>% _i18n{positiv}) <?php if ($user['vote']!=NULL){?><a href="#" title="Extended">Extended</a><?php } ?></p>
																</div>
																<div class="extendRating">
																	<dl>
																		<dt>_i18n{Quality of work}:</dt>
																		<dd><span class="itemCurrent" style="width:<?php echo $user[CompanyService::VOTE1] ?>%"></span></dd>
																	</dl>
																	<dl>
																		<dt>_i18n{Reliability}:</dt>
																		<dd><span class="itemCurrent" style="width:<?php echo $user[CompanyService::VOTE2] ?>%"></span></dd>
																	</dl>
																	<dl>
																		<dt>_i18n{Cleanliness}:</dt>
																		<dd><span class="itemCurrent" style="width:<?php echo $user[CompanyService::VOTE3] ?>%"></span></dd>
																	</dl>
																	<dl>
																		<dt>_i18n{Price/Performance}:</dt>
																		<dd><span class="itemCurrent" style="width:<?php echo $user[CompanyService::VOTE4] ?>%"></span></dd>
																	</dl>
																	<dl>
																		<dt>_i18n{Project delivered}:</dt>
																		<dd><span class="itemCurrent" style="width:<?php echo $user[CompanyService::VOTE5] ?>%"></span></dd>
																	</dl>
																	<dl>
																		<dt>_i18n{Consulting Services}:</dt>
																		<dd><span class="itemCurrent" style="width:<?php echo $user[CompanyService::VOTE6] ?>%"></span></dd>
																	</dl>
																	<p><a href="#" title="Avarage">Avarage</a></p>
																</div>
															</div>
														</dd>
													</dl>
												</div>
												<div class="unitEqColumns">
													<dl>
														<dt>_i18n{category}:</dt>
														<dd><?php echo $user[CategoryService::CAT_NAME] ?></dd>
													</dl>
													<dl>
														<dt>_i18n{subcategory}:</dt>
														<dd><?php echo $user[SubCategoryService::SUBCAT_NAME] ?></dd>
													</dl>
													<dl>
														<dt>_i18n{address}:</dt>
														<dd><?php echo $user[UsersService::ADDRESS] ?>, <?php echo $user[UsersService::LOCATION] ?></dd>
														<dd><?php echo $user[RegionService::REGION_NAME] ?> , <?php echo $user[CountryService::COUNTRY_NAME] ?></dd>
													</dl>
												</div>
											</div>
											<div class="itemQuote">
												<button><span><strong>_i18n{Get a Quote}</strong></span></button>
											</div>
										</div>
									<?php }
									} else { ?>
										_i18n{No company like you whant}
									<?php } ?>
								</div>
								<div class="unitPagination unitBPagination">
									<div class="itemPage">
										<label>_i18n{Items per page}:</label>
										<select name="onpage">
											<option <?php echo isset($_GET['onpage'])&&$_GET['onpage']==5 ? "selected='selected'" : NULL ; ?>>5</option>
											<option <?php echo isset($_GET['onpage'])&&$_GET['onpage']==10 ? "selected='selected'" : NULL ; ?>>10</option>
											<option <?php echo isset($_GET['onpage'])&&$_GET['onpage']==50 ? "selected='selected'" : NULL ; ?>>50</option>
										</select>
									</div>
									<ul>
										<?php for($i=0; $i<$pages; $i++){ ?>
											<li>
											<?php if(isset($_GET['page'])&&$_GET['page']==$i+1  || !isset($_GET['page'])&&$i==0) { ?>
												<span><?php echo $i+1; ?></span>
											<?php }else{ ?>
												<a href="/view-orders.html?&page=<?php echo $i+1; ?>
													<?php echo isset($_GET['category_id']) ? '&category_id='.$_GET["category_id"] : NULL ; ?>
													<?php echo isset($_GET['subcategory_id']) ? '&subcategory_id='.$_GET["subcategory_id"] : NULL ; ?>
													<?php echo isset($_GET['country_id']) ? '&country_id='.$_GET["country_id"] : NULL ; ?>
													<?php echo isset($_GET['region_id']) ? '&region_id='.$_GET["region_id"] : NULL ; ?>
													<?php echo isset($_GET['price_from']) ? '&price_from='.$_GET["price_from"] : NULL ; ?>
													<?php echo isset($_GET['price_until']) ? '&price_until='.$_GET["price_until"] : NULL ; ?>
													<?php echo isset($_GET['order_name']) ? '&order_name='.$_GET["order_name"] : NULL ; ?>
													<?php echo isset($_GET['onpage']) ? '&onpage='.$_GET["onpage"] : NULL ; ?>
													<?php echo isset($_GET['search']) ? '&search='.$_GET["search"] : NULL ; ?>" title="1">
												<?php echo $i+1; ?>
												</a>
											<?php }?>
											</li>
										<?php } ?>
									</ul>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
			<div class="cB"><em class="cL"></em><em class="cR"></em></div>
		</div>
	</div>
</div>